package cn.buk.tms.eotms.dto;

import cn.buk.common.util.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;

/**
 * @author yfdai
 */
public class TicketSaleDto {

    /**
     * 客票未使用状态
     */
    private static final String TICKET_STATUS_USED = "0";
    /**
     * 客票已使用
     */
    private static final String TICKET_STATUS_UNUSED = "2";

    private int id;

    private int enterpriseId;

    private String ticketNo;

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date sellDate;

    /**
     * 0-国内
     * 1-国际
     */
    private Integer type3;

    private String balCode;

    private String orig;

    private String dest;

    private String pnrNo;

    /**
     * 出票office
     */
    private String officeNo;

    private int deviceId;

    private Double price;

    private Double commission;

    private Double tax;

    private Integer supplierId;

    private double bottomPrice;

    private int ctcmCount;

    private String detail;

    private Integer status;

    private Integer ticketStatus;

    private String conjTag;

    private String operator;

    private Integer checkStatus;

    private String billNum;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;


    // 以下信息来自Pnr(t240)

    private String etermUsername;

    private String linkPhone;

    /**
     * 航段状态
     */
    private String segStatus;

    private Integer segCount;

    private Integer psgCount;

    private Date pnrCreateTime;

    /**
     * 预定office
     */
    private String bookingOffice;

    //   以下信息来自DetrInfo

    private String psgName;

    private String segInfo;

    private String carrier;

    private String flightNo;

    private String subclass;

    private String fltDate;

    private Double taxCn;

    private Double taxYq;

    private Double taxOt;



    private Double fare;

    private Double totalFare;

    private String luggage;

    private String isUsed;

    private String detrDetail;


    /**
     * 以下记录从rtkt中获取的内容
     */
    private String rtktDetail;

    /**
     * 票样中的fc项
     */
    private String fc;

    /**
     * 始发国货币
     */
    private String fromCurrency;

    /**
     * 始发国票价（不含税)
     */
    private Double fromFare;

    /**
     * 本地货币
     */
    private String localCurrency;

    /**
     * 本地货币票价（不含税，人民币）
     */
    private Double localFare;

    /**
     * NUC计算的票价（不含税）
     */
    private Double nucFare;

    private Double roe;

    /**
     * 记录RTKT中total fare栏中显示的BT等状态
     */
    private String totalFareNone;

    private String totalFareCurrency;

    private Double totalTax;

    /**
     * 净价
     */
    private Double netFare;


    public static StringBuffer exportTitle() {
        StringBuffer sb = new StringBuffer();

        sb = sb.append("eterm用户名,");
        sb = sb.append("票号,");
        sb = sb.append(",");
        sb = sb.append(",");
        sb = sb.append("打票机号,");
        sb = sb.append("出票日期,");
        sb = sb.append("编码,");
        sb = sb.append("ctcm,");
        sb = sb.append("ctct,");


        sb = sb.append("航空公司,");
        sb = sb.append("航段状态,");
        sb = sb.append("航段数量,");
        sb = sb.append("乘客数量,");

        sb = sb.append("乘客姓名,");
        sb = sb.append("航段,");
        sb = sb.append("航班,");
        sb = sb.append("舱位,");
        sb = sb.append("日期,");
        sb = sb.append("价格,");
        sb = sb.append("税,");
        sb = sb.append("佣金,");
        sb = sb.append("底价,");

        sb = sb.append("使用状态,");
        sb = sb.append("编码生成时间,");
        sb = sb.append("出票Office,");
        sb = sb.append("预定Office,");
        sb = sb.append("ROE,");
        sb = sb.append("NUC,");


        sb = sb.append("\r");

        return sb;
    }

    public StringBuffer exportContent() {
        StringBuffer sb = new StringBuffer();

        sb = sb.append(this.etermUsername);
        sb = sb.append(",");
        sb = sb.append(this.ticketNo).append(",");
        if (this.ticketStatus == null) {

        } else if (this.ticketStatus == 1) {
            sb = sb.append("改签");
        } else if (this.ticketStatus == 4) {
            sb = sb.append("退票");
        } else if (this.ticketStatus == 16) {
            sb = sb.append("废");
        }
        sb = sb.append(",");
        sb = sb.append(this.getConjTag()).append(",");
        sb = sb.append(this.deviceId);
        sb = sb.append(",");
        sb = sb.append(this.sellDate);
        sb = sb.append(",");
        sb = sb.append(this.pnrNo);
        sb = sb.append(",");
        sb = sb.append(this.ctcmCount);
        sb = sb.append(",");
        sb = sb.append(this.linkPhone);
        sb = sb.append(",");


        sb = sb.append(this.carrier);
        sb = sb.append(",");
        sb = sb.append(this.segStatus);
        sb = sb.append(",");
        sb = sb.append(this.segCount);
        sb = sb.append(",");
        sb = sb.append(this.psgCount);
        sb = sb.append(",");

        sb = sb.append(this.psgName);
        sb = sb.append(",");
        sb = sb.append(this.segInfo);
        sb = sb.append(",");
        sb = sb.append(this.flightNo);
        sb = sb.append(",");
        sb = sb.append(this.subclass);
        sb = sb.append(",");
        sb = sb.append(this.fltDate);
        sb = sb.append(",");

        sb = sb.append(this.price).append(",");
        sb = sb.append(this.tax).append(",");
        sb = sb.append(this.commission).append(",");
        sb = sb.append(this.bottomPrice).append(",");

        sb = sb.append(this.getUseStatus());
        sb = sb.append(",");

        if (this.pnrCreateTime == null) {
            sb = sb;
        } else {
            sb = sb.append(DateUtil.formatDate(this.pnrCreateTime));
        }
        sb = sb.append(",");
        sb = sb.append(this.officeNo);
        sb = sb.append(",");
        sb = sb.append(this.bookingOffice);
        sb = sb.append(",");
        sb = sb.append(this.roe);
        sb = sb.append(",");
        sb = sb.append(this.nucFare);
        sb = sb.append(",");

        sb = sb.append("\r");

        return sb;
    }



    public String getUseStatus() {
        if (TICKET_STATUS_USED.equalsIgnoreCase(this.isUsed)) {
            return "未使用";
        } else if (TICKET_STATUS_UNUSED.equalsIgnoreCase(this.isUsed)) {
            return "已使用";
        } else {
            return "";
        }
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getEnterpriseId() {
        return enterpriseId;
    }

    public void setEnterpriseId(int enterpriseId) {
        this.enterpriseId = enterpriseId;
    }

    public String getTicketNo() {
        return ticketNo;
    }

    public void setTicketNo(String ticketNo) {
        this.ticketNo = ticketNo;
    }

    public Date getSellDate() {
        return sellDate;
    }

    public void setSellDate(Date sellDate) {
        this.sellDate = sellDate;
    }

    public String getBalCode() {
        return balCode;
    }

    public void setBalCode(String balCode) {
        this.balCode = balCode;
    }

    public String getOrig() {
        return orig;
    }

    public void setOrig(String orig) {
        this.orig = orig;
    }

    public String getPnrNo() {
        return pnrNo;
    }

    public void setPnrNo(String pnrNo) {
        this.pnrNo = pnrNo;
    }

    public String getOfficeNo() {
        return officeNo;
    }

    public void setOfficeNo(String officeNo) {
        this.officeNo = officeNo;
    }

    public int getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(int deviceId) {
        this.deviceId = deviceId;
    }

    public int getCtcmCount() {
        return ctcmCount;
    }

    public void setCtcmCount(int ctcmCount) {
        this.ctcmCount = ctcmCount;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getDest() {
        return dest;
    }

    public void setDest(String dest) {
        this.dest = dest;
    }

    public Double getTaxCn() {
        return taxCn == null ? 0 : taxCn;
    }

    public void setTaxCn(Double taxCn) {
        this.taxCn = taxCn;
    }

    public Double getTaxYq() {
        return taxYq == null ? 0 : taxYq;
    }

    public void setTaxYq(Double taxYq) {
        this.taxYq = taxYq;
    }

    public Double getTaxOt() {
        return taxOt == null ? 0 : taxOt;
    }

    public void setTaxOt(Double taxOt) {
        this.taxOt = taxOt;
    }

    public Double getTax() {
        return tax == null ? 0 : tax;
    }

    public void setTax(Double tax) {
        this.tax = tax;
    }

    public Double getFare() {
        return fare == null ? 0 : fare;
    }

    public void setFare(Double fare) {
        this.fare = fare;
    }

    public Double getTotalFare() {
        return totalFare == null ? 0 : totalFare;
    }

    public void setTotalFare(Double totalFare) {
        this.totalFare = totalFare;
    }

    public String getPsgName() {
        return psgName;
    }

    public void setPsgName(String psgName) {
        this.psgName = psgName;
    }

    public String getSegInfo() {
        return segInfo;
    }

    public void setSegInfo(String segInfo) {
        this.segInfo = segInfo;
    }

    public String getCarrier() {
        return carrier;
    }

    public void setCarrier(String carrier) {
        this.carrier = carrier;
    }

    public String getFlightNo() {
        return flightNo;
    }

    public void setFlightNo(String flightNo) {
        this.flightNo = flightNo;
    }

    public String getSubclass() {
        return subclass;
    }

    public void setSubclass(String subclass) {
        this.subclass = subclass;
    }

    public String getFltDate() {
        return fltDate;
    }

    public void setFltDate(String fltDate) {
        this.fltDate = fltDate;
    }

    public String getLuggage() {
        return luggage;
    }

    public void setLuggage(String luggage) {
        this.luggage = luggage;
    }

    public String getIsUsed() {
        return isUsed;
    }

    public void setIsUsed(String isUsed) {
        this.isUsed = isUsed;
    }

    public String getDetrDetail() {
        return detrDetail;
    }

    public void setDetrDetail(String detrDetail) {
        this.detrDetail = detrDetail;
    }

    public String getEtermUsername() {
        return etermUsername == null ? "" : etermUsername.trim();
    }

    public void setEtermUsername(String etermUsername) {
        this.etermUsername = etermUsername;
    }

    public String getLinkPhone() {
        return linkPhone;
    }

    public void setLinkPhone(String linkPhone) {
        this.linkPhone = linkPhone;
    }

    public String getSegStatus() {
        return segStatus;
    }

    public void setSegStatus(String segStatus) {
        this.segStatus = segStatus;
    }

    public Integer getSegCount() {
        return segCount;
    }

    public void setSegCount(Integer segCount) {
        this.segCount = segCount;
    }

    public Date getPnrCreateTime() {
        return pnrCreateTime;
    }

    public void setPnrCreateTime(Date pnrCreateTime) {
        this.pnrCreateTime = pnrCreateTime;
    }

    public String getBookingOffice() {
        return bookingOffice;
    }

    public void setBookingOffice(String bookingOffice) {
        this.bookingOffice = bookingOffice;
    }

    public void setPsgCount(Integer psgCount) {
        this.psgCount = psgCount;
    }

    public Integer getStatus() {
        return status == null ? 0 : status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRtktDetail() {
        return rtktDetail;
    }

    public void setRtktDetail(String rtktDetail) {
        this.rtktDetail = rtktDetail;
    }

    public String getFc() {
        return fc;
    }

    public void setFc(String fc) {
        this.fc = fc;
    }

    public Double getRoe() {
        return roe;
    }

    public void setRoe(Double roe) {
        this.roe = roe;
    }

    public String getFromCurrency() {
        return fromCurrency;
    }

    public void setFromCurrency(String fromCurrency) {
        this.fromCurrency = fromCurrency;
    }

    public Double getFromFare() {
        return fromFare;
    }

    public void setFromFare(Double fromFare) {
        this.fromFare = fromFare;
    }

    public String getLocalCurrency() {
        return localCurrency;
    }

    public void setLocalCurrency(String localCurrency) {
        this.localCurrency = localCurrency;
    }

    public Double getLocalFare() {
        return localFare;
    }

    public void setLocalFare(Double localFare) {
        this.localFare = localFare;
    }

    public Double getNucFare() {
        return nucFare;
    }

    public void setNucFare(Double nucFare) {
        this.nucFare = nucFare;
    }

    public String getTotalFareNone() {
        return totalFareNone;
    }

    public void setTotalFareNone(String totalFareNone) {
        this.totalFareNone = totalFareNone;
    }

    public String getTotalFareCurrency() {
        return totalFareCurrency;
    }

    public void setTotalFareCurrency(String totalFareCurrency) {
        this.totalFareCurrency = totalFareCurrency;
    }

    public void setTotalTax(Double totalTax) {
        this.totalTax = totalTax;
    }

    public Double getNetFare() {
        return netFare;
    }

    public void setNetFare(Double netFare) {
        this.netFare = netFare;
    }

    public Integer getType3() {
        return type3;
    }

    public void setType3(Integer type3) {
        this.type3 = type3;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getCommission() {
        return commission;
    }

    public void setCommission(Double commission) {
        this.commission = commission;
    }

    public Integer getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Integer supplierId) {
        this.supplierId = supplierId;
    }

    public double getBottomPrice() {
        return bottomPrice;
    }

    public void setBottomPrice(double bottomPrice) {
        this.bottomPrice = bottomPrice;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public Integer getCheckStatus() {
        return checkStatus;
    }

    public void setCheckStatus(Integer checkStatus) {
        this.checkStatus = checkStatus;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getBillNum() {
        return billNum;
    }

    public void setBillNum(String billNum) {
        this.billNum = billNum;
    }

    public Integer getPsgCount() {
        return psgCount;
    }

    public Double getTotalTax() {
        return totalTax;
    }

    public Integer getTicketStatus() {
        return ticketStatus;
    }

    public void setTicketStatus(Integer ticketStatus) {
        this.ticketStatus = ticketStatus;
    }

    public String getConjTag() {
        return conjTag == null ? "": conjTag.trim();
    }

    public void setConjTag(String conjTag) {
        this.conjTag = conjTag;
    }
}
